﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using BOMS.DBUtility;//请先添加引用
namespace BOMS.DAL
{
    /// <summary>
    /// 数据访问类S_BatgrpSubLog。
    /// </summary>
    public class S_BatgrpSubLog
    {
        public S_BatgrpSubLog()
        { }
        #region  成员方法

      

       
        public void AssignModel(DataRow dr, Model.S_BatgrpSubLog model)
        {
            if (dr.Table.Columns.Contains("LogID") && dr["LogID"].ToString() != "")
            {
                model.LogID = (long)dr["LogID"];
            }
            if (dr["Generation"].ToString() != "")
            {
                model.Generation = int.Parse(dr["Generation"].ToString());
            }
            model.EquipID = dr["EquipID"].ToString();
            model.BatteryGroup = dr["BatteryGroup"].ToString();
            if (dr["Vval"].ToString() != "")
            {
                model.Vval = decimal.Parse(dr["Vval"].ToString());
            }
            if (dr["Ival"].ToString() != "")
            {
                model.Ival = decimal.Parse(dr["Ival"].ToString());
            }
            if (dr["CdFree"].ToString() != "")
            {
                model.CdFree = decimal.Parse(dr["CdFree"].ToString());
            }
            if (dr["CdTime"].ToString() != "")
            {
                model.TimeFree = dr["CdTime"].ToString();
            }
            if (dr["CapFree"].ToString() != "")
            {
                model.CapFree = decimal.Parse(dr["CapFree"].ToString());
            }
            if (dr["TimeFree"].ToString() != "")
            {
                model.TimeFree = dr["TimeFree"].ToString();
            }
            if (dr["WorkStatus"].ToString() != "")
            {
                model.WorkStatus = byte.Parse(dr["WorkStatus"].ToString());
            }
            if (dr["WarningContent"].ToString() != "")
            {
                model.WarningContent = int.Parse(dr["WarningContent"].ToString());
            }
            model.Status = dr["Status"].ToString();
            model.WarningContentDescr = dr["WarningContentDescr"].ToString();
            if (dr["LogTime"].ToString() != "")
            {
                model.LogTime = DateTime.Parse(dr["LogTime"].ToString());
            }
        }
        
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetListFromPage(string strWhere, string strOrderby, int pageSize, int curPage, out int recordCount)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select LogID,Generation,EquipID,BatteryGroup,Vval,Ival,CdFree,CdTime,CapFree,TimeFree,WorkStatus,WarningContent,Status,WarningContentDescr,LogTime ");
            strSql.Append(" FROM S_BatgrpSubLog ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DALUti.GetPageData(strSql.ToString(), strOrderby, pageSize, curPage, out recordCount);
        }

        #endregion  成员方法
    }
}

